<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ page language = "java"	import="java.io.*,java.sql.*" %>

<%@include file="dbcon.jsp"%>
<%
// Not Login or User Not Admin
	if ( session.getAttribute("SES_USERSNO") == null || (Integer)session.getAttribute("SES_USERTYPE") != 1  )
	{
		response.sendRedirect("index.jsp");
		return;
	}
	
	int iSno = 0;
	int iRecType = 1;
	int iUserType = 1;
	String sTmp = "";
	String sModel = "";
	
	sTmp = request.getParameter("ModelID");
	if ( sTmp != null && !sTmp.equals("") )
		iSno = Integer.parseInt(sTmp);
	sTmp = request.getParameter("RecType");
	if ( sTmp != null && !sTmp.equals("") )
		iRecType = Integer.parseInt(sTmp);		
	if ( iSno > 0 ) // Edit
	{
		iRecType = 2;
		Statement Stmt = null;
	    ResultSet Rs = null;
		try
		{
			String sQry = "select modelname from tbl_model_master where status=1 ";
			sQry += "and modelid="+ iSno;
		System.out.println(sQry);
			Stmt = Con.createStatement();
			Rs = Stmt.executeQuery(sQry);
			if ( Rs.next() )
				sModel = Rs.getString("modelname");
		}catch(Exception e){ System.out.println(e); }
		
		if (Rs != null ) Rs.close();
		if (Stmt != null ) Stmt.close();
		if (Con != null ) Con.close();
	}
%>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>eSat</title>
<!-- Common Style -->		
	<link href="file:///C|/Documents and Settings/VIMAL/Desktop/css/style.css" rel="stylesheet" type="text/css" />	
<!-- Common Validation -->				
	<script src='file:///C|/Documents and Settings/VIMAL/Desktop/js/validation.js' language='javascript' ></script>		
	<script src='file:///C|/Documents and Settings/VIMAL/Desktop/js/common.js' language='javascript' ></script>			
<!-- Form Field Validation -->			
    <link rel="stylesheet" href="file:///C|/Documents and Settings/VIMAL/Desktop/css/validationEngine.jquery.css" type="text/css"/>
	<script type="text/JavaScript" src="file:///C|/Documents and Settings/VIMAL/Desktop/jquery/jquery-1.4.2.min.js"></script>		
    <script src="file:///C|/Documents and Settings/VIMAL/Desktop/js/languages/jquery.validationEngine-en.js" type="text/javascript" charset="utf-8"></script>
    <script src="file:///C|/Documents and Settings/VIMAL/Desktop/js/jquery.validationEngine.js" type="text/javascript" charset="utf-8"> </script>
<!-- Round Corner -->				
	<script type="text/JavaScript" src="file:///C|/Documents and Settings/VIMAL/Desktop/jquery/roundcorner/jquery.curvycorners.source.js"></script>
<!-- Ajax -->
	<script src='file:///C|/Documents and Settings/VIMAL/Desktop/ajax/ajax_fn.js' language='javascript' ></script>
<!-- Menu -->	
	<link rel='stylesheet' type='text/css' href='file:///C|/Documents and Settings/VIMAL/Desktop/menu/ddsmoothmenu.css' />
	<script type='text/javascript' src='file:///C|/Documents and Settings/VIMAL/Desktop/menu/ddsmoothmenu.js' ></script>
			
<script type="text/JavaScript">
	var vLoginStatus = <%=(String)session.getAttribute("SES_USERSNO")%>;
	var vUserType = <%=iUserType%>;	
/* Form Validation */
	jQuery(document).ready(function(){
		// binds form submission and fields to the validation engine
		jQuery("#frmAdmin").validationEngine();
	});
/* Round Corner */
	$(function(){ 
	  settings = {
			  tl: { radius: 20 },
			  tr: { radius: 20 },
			  bl: { radius: 20 },
			  br: { radius: 20 },
			  antiAlias: true,
			  autoPad: true,
			  validTags: ["div"]
		  }
		  $('.myBox').corner(settings);
	  });;
/* Menu */	  
	ddsmoothmenu.init({
	mainmenuid: "smoothmenu1",
	orientation: 'h', 
	classname: 'ddsmoothmenu',
	contentsource: "markup" 
	});
</script>

<script type="text/JavaScript">

	window.onload=function(){
		CommonValidation();		
		
		var theHeight;
		if (window.innerHeight) {
			theHeight=window.innerHeight;
		}
		else if (document.documentElement && document.documentElement.clientHeight) {
			theHeight=document.documentElement.clientHeight;
		}
		else if (document.body) {
			theHeight=document.body.clientHeight;
		}
		document.getElementById('innerContent').style.minHeight = (theHeight-242) +'px';
		
		document.getElementById("txt_model").focus();
	}
	document.onkeypress = GBLVdn_StopRKey;

	function CheckDuplicate(p_id,p_value){
		if ( p_value == null  ||  GBLVdn_Trim(p_value) == "" ) return;
		var frm = document.frmAdmin;
		if ( p_id == 1 ) // User Name
		{
//			alert(document.getElementById("unameStatus"));
			var vCond = "model='"+ frm.txt_model.value +"'";
//			alert(document.getElementById("unameStatus"));			
			call_DBDuplicate("tbl_model_master",vCond,frm.txt_model,document.getElementById("unameStatus"));
		}
	}
	
	function validation(){
		//alert(document.getElementById("hid_DupRec").value);
		var value = document.getElementById("txt_model").value;
		if ( value == null  ||  GBLVdn_Trim(value) == "" ) return false;
		
		if ( document.getElementById("hid_DupRec").value == "1" )
		{
			document.getElementById("txt_model").focus();
			return false;
		}
		return true;
	}
</script>

</head>

<body>
<form id="frmAdmin" name="frmAdmin" method="post" action="file:///C|/Documents and Settings/VIMAL/Desktop/frm_model_add.jsp">
<input type='hidden' name='hid_RecType' id='hid_RecType' value='<%=(iSno<=0)?"1":"2"%>'>
<input type='hidden' name='hid_DupRec' id='hid_DupRec' value='0'>
<input type='hidden' name='hid_RecSno' id='hid_RecSno' value='<%=iSno%>'>
<table width="100%" cellpadding="0" cellspacing="0" border="0" >
<tr><td align="center">
<table width="1004px" cellpadding="0" cellspacing="0" border="0" class="formbk" >
<tr><td valign="top"><script src="file:///C|/Documents and Settings/VIMAL/Desktop/js/top.js"></script></td></tr>
<tr><td align="center">&nbsp;</td></tr>
<tr><td align="center">&nbsp;</td></tr>
<tr><td align="center"><div id="innerContent">
	<table width="50%" cellpadding="0" cellspacing="0" border="0" class="formbk" >
		<tr>
			<td class="toplink" align="left">
				<table width="100%" cellpadding="0" cellspacing="0" border="0" >
					<tr>
						<td valign="top" align="center" class="head" >Model  Details</td>
						<td class="toplink" align="right" width='12%'>
						<b class='compelseary' >*Mandatory</b>&nbsp;&nbsp;</td>
					</tr>
				</table>						
			</td>
		</tr>
		<tr>
		<td align="center" valign="top">
			<table width="100%" cellpadding="3" cellspacing="3" border="0" >
			<tr>
			<td width="80%" align="center" valign="top">
			<div class="myBox">
				<table width="100%" cellpadding="1" cellspacing="1" border="0" >
				<tr>
					<td valign="top" align="left" width="30%" >&nbsp;&nbsp;Model Name </td>
					<td valign="top" align="middle" width="1%" >:</td>
					<td valign="top" align="left" width="69%">

						<input type="text" size="40" value='<%=sModel%>' class="validate[required] text-input" name="txt_model" id="txt_model" tabindex="4" onblur="CheckDuplicate(1,this.value);" maxlength="45"/>&nbsp;<b class='mandatory' >*</b>&nbsp;<span id="unameStatus" name="unameStatus"></span>
					</td>
				</tr>
				</table>
			</div></td></tr>
			</table>
		</td></tr>
		<tr>
<% if ( iRecType == 1 || iRecType == 2 ) { %>		
			<td align='center' colspan='2' >
				<input class="regular" type="submit" id="mysubmit" onclick="return validation();" value="<%=(iSno==0)?"Save":"Update"%>" tabindex="9" />
			</td>
		</tr>
<% } %>		
		</table></div>			
</td></tr>
<tr><td valign="top" align="center"><script src="file:///C|/Documents and Settings/VIMAL/Desktop/js/bottom.js"></script></td></tr>
</table>
</td></tr></table>
</td></tr></table>
</form>
</body>
</html>